	$(function() {

		$( "#dialog:ui-dialog" ).dialog( "destroy" );

		$( "#dialog-modal" ).dialog({
			modal: true
		});

                $( "#dialog:ui-dialog" ).dialog( "destroy" );

		$( ".message" ).dialog({
			modal: true
		});
                
		$( "#ProfilDateNaissance" ).datepicker({
                    
                    changeMonth: true,
	            changeYear: true,
                    yearRange: 'c-100:c'

                }
    
        );


		$( "#expediteur" ).autocomplete({
			source: "<?php echo $this->Html->url('/javascripts/expediteur', true); ?>",
                        minLength: 2,
			select: function( event, ui ) {
				log( ui.item ?
					ui.item.value :
					"Nothing selected, input was " + this.value );
                                    event.target.value = '';
                                    return false;
			}
		});
            $( "#ProfilDateNaissance" ).datepicker.regional['fr'];          

                });
                
function log( message ) {

var valeur = $( "input#destinataire" ).val();

if (valeur != '') {
    
    valeur = valeur+";";
            
        }
   
$( "input#destinataire" ).val(valeur+''+message);

}


function online(){
$.ajax({
  url: "<?php echo $this->Html->url('/utilisateurs/online', true); ?>",
  cache: false,
  success: function(html){
    $("#online").html(html);
  }
})
}

function utilisateurOnline(pseudo){
$.ajax({
  url: "<?php echo $this->Html->url('/utilisateurs/utilisateur_online', true); ?>/" + pseudo,
  cache: false,
  success: function(html){
    $("#online_"+ pseudo).html(html);
  }
})
}

setInterval('online()',1000);
